# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
pkgname=sdl2_mixer
pkgver=2.0.4
pkgrel=7
pkgdesc="A simple multi-channel audio mixer (Version 2)"
arch=('x86_64')
url="http://www.libsdl.org/projects/SDL_mixer"
license=('MIT')
depends=('sdl2' 'libvorbis' 'libmodplug' 'mpg123' 'flac' 'opusfile')
makedepends=('fluidsynth')
optdepends=('fluidsynth: MIDI software synth, replaces built-in timidity')
source=("https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-${pkgver}.tar.gz"
        fix-fluidsynth-2.1.6.patch::https://hg.libsdl.org/SDL_mixer/raw-rev/b0afe341a91d)
sha512sums=('98c56069640668aaececa63748de21fc8f243c7d06386c45c43d0ee472bbb2595ccda644d9886ce5b95c3a3dee3c0a96903cf9a89ddc18d38f041133470699a3'
            '21e130a5116115f3cfa00ba6f3b0f2b816ed3abf071340d4b218a3e8dc79bb74b042faf15daa2f06c47f6bdc3737a2542708f070d0f48c53acd888e0436161fd')

prepare() {
  cd "${srcdir}/SDL2_mixer-${pkgver}/"

  sed -i "s|/etc/timidity|/etc/timidity++|g" timidity/options.h
  sed -i "s|/etc/timidity++.cfg|/etc/timidity++/timidity.cfg|g" timidity/options.h

  patch -Np3 -i "${srcdir}/fix-fluidsynth-2.1.6.patch"
}

build() {
  cd "${srcdir}/SDL2_mixer-${pkgver}/"

  ./configure --disable-static --prefix=/usr
  make
}

package() {
  cd "${srcdir}/SDL2_mixer-${pkgver}/"

  make DESTDIR="${pkgdir}" install
  install -Dm644 COPYING.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
